package com.biz.hunter.dao;

import org.springframework.stereotype.Repository;

import com.biz.hunter.db.entity.OrderLeave;
import com.biz.hunter.dbutil.BaseDAO;

@Repository
public class OrderLeaveDAO {
	private static final String SQL_GET_ID = "select * from tb_order_leave where id = ?";
	private static final String SQL_SAVE = "INSERT INTO tb_order_leave(openid, orderId,employeeId,hunterId,ordescId,"
			+ "monthlypay,month,salary,reward,"
			+ "remark,reason,createtime,updatetime) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)";
	private static final String SQL_GET_ORDERID="select * from tb_order_leave where orderId=?";
	
	public OrderLeave getLeaveById(long Id) {
		return BaseDAO.queryForObject(OrderLeave.class, SQL_GET_ID, Id);
	}

	public OrderLeave getLeaveByOrderId(long orderId){
		return BaseDAO.queryForObject(OrderLeave.class, SQL_GET_ORDERID, orderId);
	}
	
	public long saveOrderLeave(OrderLeave leave) {
		if (leave == null) {
			return -1;
		}

		Long result = BaseDAO.save(SQL_SAVE, leave.getOpenid(), leave.getOrderId(),
				leave.getEmployeeId(),leave.getHunterId(),leave.getOrdescId(),
				leave.getMonthlypay(),leave.getMonth(),leave.getSalary(),leave.getReward(),
				leave.getRemark(),leave.getReason(),leave.getCreatetime(),leave.getUpdatetime());
		if (result != null) {
			return result.longValue();
		}
		return -1;
	}
	


}
